package action;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

import analyser.CmdAnalyserImp;

public class NetworkProcessAction{
	CmdAnalyserImp cmdAnalyser;
	
	
	public NetworkProcessAction() throws FileNotFoundException {
		cmdAnalyser = new CmdAnalyserImp();
	}

	public void networkDataProcess(StringBuilder s) throws IOException {
			ServerSocket server = new ServerSocket(8889);
			Socket socket = server.accept();	
			OutputStream out = socket.getOutputStream();
			InputStream in = socket.getInputStream();
			
			out.write("please enter a commad:    ".getBytes());
			BufferedReader reader = new BufferedReader(new InputStreamReader(in));
			
			BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
			while(true){
				String cmd = reader.readLine();
				cmdAnalyser.cmdAnalyseAndHandle(cmd);     //获得命令参数，传入
				
				
			}
			
	}
	
}
